#ifndef __INCUserManagerh
#define __INCUserManagerh
#include <unordered_map>
#include <mutex>
#include <objbase.h>
#include <UserInfo.h>

using UserInfoMap = std::unordered_map<std::string, UserInfo>;
class UserManager : public objbase
{
private:
    DISABLE_COPY_CLASS(UserManager);
    mutable std::mutex m_userMutex;
    UserInfoMap m_users;

private:
    std::string sha256(const std::string& input);
    STATUS initBuiltinUsers();
    STATUS saveUserConfig();
    PROCESS_DESC(sysShutdown);

public:
    DECLARE_CTOR_DTOR(UserManager);
    OBJBASE_EXTERN_MEMBER_IMPL();
    UserPermission verifyUser(const std::string& username, const std::string& password);
    STATUS addUser(const std::string& username, const std::string& password, UserPermission permission);
    STATUS deleteUser(const std::string& username);
};
#endif